import 'package:flutter/material.dart';

class ListViewSeparatedCast extends StatelessWidget {
  const ListViewSeparatedCast({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // 同时设置分割线 和内容
    return ListView.separated(
        itemBuilder: (BuildContext context, int index) {
          return Container(
            width: double.infinity,
            margin: EdgeInsets.all(10),
            decoration: BoxDecoration(
                color: Colors.blue, borderRadius: BorderRadius.circular(10)),
            height: 100,
            alignment: Alignment.center,
            child: Text(
              "第${index + 1}个",
              style: TextStyle(color: Colors.white, fontSize: 30),
            ),
          );
        },
        itemCount: 5, // 循环的次数
        // 分割线的渲染内容
        separatorBuilder: (BuildContext context, int index) {
          return Container(
            width: double.infinity,
            margin: EdgeInsets.only(top: 20, bottom: 20),
            height: 1,
            color: Color.fromRGBO(0, 0, 0, 1),
          );
        });
  }
}
